<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['prefix' => '/v1'], function (){
    Route::middleware(['user_auth'])->group(function () {

        //登录
        Route::get('/login/background/{startTime}/{endTime}', 'User\LoginController@currentLoginBackground');
        Route::post('/login/username', 'User\LoginController@usernameLogin');
        Route::post('/login/phone', 'User\LoginController@phoneLogin');
        Route::post('/login/admin/email', 'Admin\LoginController@emailLogin');
        Route::post('/login/phone/verify', 'User\LoginController@phoneLoginSendVerifyCode');

        //首页
        Route::get('/user/indexBanner','User\IndexController@indexTopBanner');
        Route::post('/user/addIntroduces','User\IndexController@addCommunityIntroduces');
        Route::get('/user/introduces','User\IndexController@getCommunityIntroduces');
        Route::post('/user/addAward','User\IndexController@addCommunityAward');
        Route::get('/user/award','User\IndexController@getCommunityAward');
        Route::get('/user/personIntroduces','User\IndexController@personIntroduction');
        Route::get('/user/learnEnvironment','User\IndexController@learnEnvironment');

        //用户
        Route::group([], function () {
            Route::get('/role/route', 'User\UserController@getRouteList');

            //用户操作
            Route::put('/user/password', 'User\LoginController@updatePass');
            Route::post('/user/first/verify', 'User\LoginController@firstLoginSendVerifyCode');
            Route::put('/user/phone', 'User\LoginController@updatePhone');
            Route::put('/user/time', 'User\LoginController@refreshUserTime');
            Route::delete('/user/logout', 'User\LoginController@loginOut');

            //周报
            Route::post('/user/weekly', 'User\WeekliesController@addWeekly');
            Route::post('/user/weekly/file', 'User\WeekliesController@weeklyUploadFile');
            Route::delete('/user/weekly/file', 'User\WeekliesController@weeklyDeleteFile');
            Route::post('/user/weekly/likes/{id}', 'User\WeekliesController@weeklyLike');
            Route::put('/user/weekly/browse/{id}', 'User\WeekliesController@updateWeeklyBrowse');
            Route::get('/user/weekly/release', 'User\WeekliesController@releaseLabel');
            Route::get('/user/weekly/author', 'User\WeekliesController@excellentAuthor');
            Route::get('/user/weekly/list/{label}/{type}', 'User\WeekliesController@getWeeklyList');
            Route::get('/user/weekly/{id}', 'User\WeekliesController@getWeekly');

            //学时
            Route::get('/user/learningTime/rank','User\LearningTimeController@learningTimeRank');
            Route::get('/user/learningTime/pull','User\LearningTimeController@pullRecordTime');
            Route::put('/user/learningTime/start','User\LearningTimeController@startTime');
            Route::post('/user/learningTime/end','User\LearningTimeController@endTime');
            Route::get('/user/learningTime/info','User\LearningTimeController@userInfo');

            //学习进度
            Route::post('/user/study/schedule', 'User\StudyScheduleController@addSchedule');
            Route::get('/user/study/schedule', 'User\StudyScheduleController@getSchedule');

        });

        //管理员
        Route::group([], function () {
            //导航栏
            Route::post('/navigation/admin', 'Admin\NavigationController@creatNav');
            Route::get('/navigation/all', 'Admin\NavigationController@getAllNav');
            Route::delete('/navigation', 'Admin\NavigationController@delNav');
            Route::delete('/navigation/many', 'Admin\NavigationController@delNavMany');
            Route::put('/navigation', 'Admin\NavigationController@updateNav');

            //周报
            Route::get('/weekly/all', 'Admin\WeekliesController@getWeekly');
            Route::get('/weekly/ok', 'Admin\WeekliesController@selOkWeely');
            Route::delete('/weekly/admin/{weekly_id}', 'Admin\WeekliesController@delWeekly');
            Route::delete('/weekly/user/{weekly_id}', 'Admin\WeekliesController@delUserWeekly');
            Route::put('/weekly', 'Admin\WeekliesController@updateWeekly');


            //学期管理
            Route::post('/semester', 'Admin\SystemctlController@createSemesters');
            Route::get('/semester/new', 'Admin\SystemctlController@newSemester');
            Route::put('/semester/new', 'Admin\SystemctlController@setSemester');
            Route::put('/semester', 'Admin\SystemctlController@updateSemester');
            Route::get('/semester', 'Admin\SystemctlController@getSemester');
            Route::delete('/semester', 'Admin\SystemctlController@delSemester');

            //轮播图
            Route::get('/banner/all', 'Admin\BannerController@selBanners');
            Route::get('/banner/type', 'Admin\BannerController@selBannerType');
            Route::post('/banner', 'Admin\BannerController@creatBanners');
            Route::post('/banner/new', 'Admin\BannerController@updateBanners');
            Route::delete('/banner', 'Admin\BannerController@delBanners');


            //管理员功能
            Route::get('/functions/all', 'Admin\SystemctlController@getAdminFunction');
            Route::get('/functions/class', 'Admin\SystemctlController@getFunctionClass');
            Route::post('/functions', 'Admin\SystemctlController@creatAdminFunction');
            Route::delete('/functions', 'Admin\SystemctlController@delAdminFunction');

            //通知
            Route::get('/notice', 'Admin\SystemctlController@getNotice');
            Route::put('/notice', 'Admin\SystemctlController@redNotice');
            Route::put('/notice/all', 'Admin\SystemctlController@redAllNotice');

            //用户
            Route::post('/user/one', 'Admin\AdminController@creatUser');
            Route::post('/user/batch', 'Admin\AdminController@batchCreateUser');
            Route::get('/user/userinfo', 'Admin\AdminController@getUserInfo');
            Route::get('/user/screen', 'Admin\AdminController@screenUser');
            Route::put('/user/userinfo', 'Admin\AdminController@updateUserInfo');
            Route::delete('/user/userinfo', 'Admin\AdminController@delUser');
            Route::delete('/user/batch', 'Admin\AdminController@batchDelUser');

            Route::put('/user/reset', 'Admin\AdminController@resetUser');

            //年级
            Route::get('/grades', 'Admin\AdminController@getGrades');
            Route::post('/grades', 'Admin\AdminController@creatGrades');

            //职位（权限）
            Route::get('/roles', 'Admin\AdminController@getRoles');

            //社团介绍
            Route::get('/admin/introduce', 'Admin\AdminController@getIntroduce');
            Route::post('/admin/introduce', 'Admin\AdminController@updateIntroduce');
            Route::post('/admin/presidentqrcode', 'Admin\AdminController@updatePresidentQrcode');
            Route::post('/presidentqrcode', 'Admin\AdminController@createPresidentQrcode');
            Route::delete('/admin/presidentqrcode', 'Admin\AdminController@deletePresidentQrcode');
            Route::get('/admin/award', 'Admin\AdminController@getAward');
            Route::post('/admin/award', 'Admin\AdminController@updateAward');
            Route::post('/award', 'Admin\AdminController@createAward');
            Route::delete('/admin/award', 'Admin\AdminController@deleteAward');
            Route::get('/admin/leader', 'Admin\AdminController@getLeader');
            Route::get('/admin/leader/unintroduce', 'Admin\AdminController@getUnIntroduceLeader');
            Route::get('/grade/president/unqrcode', 'Admin\AdminController@getUnIntroduceQrcode');
            Route::post('/admin/leader', 'Admin\AdminController@updateLeader');
            Route::post('/leader', 'Admin\AdminController@createLeader');
            Route::delete('/admin/leader', 'Admin\AdminController@deleteLeader');


            //节点控制
            Route::post('/admin/note', 'Admin\NoteController@addRoute');
            Route::delete('/admin/note', 'Admin\NoteController@deleteRoute');
            Route::delete('/admin/batchnote', 'Admin\NoteController@batchDeleteRoute');
            Route::put('/admin/note', 'Admin\NoteController@updateRoute');
            Route::get('/admin/note', 'Admin\NoteController@selectRoute');
            Route::put('/admin/note/status', 'Admin\NoteController@updateRouteStatus');
            Route::put('/admin/batchnote/status', 'Admin\NoteController@batchUpdateRouteStatus');
        });
    });

    //lz专用路由
    Route::get('/lz/goods_list', 'User\LzSpecialUseController@getGoodList');
    Route::get('/lz/goods_detail', 'User\LzSpecialUseController@getGoodDetail');
});

